pp108 : Current Context

Current Context

The Current Context of a business element is the parent element defined under a business object and not the business object itself. For any data, only one business object is possible, although there can be zero or more current contexts. This is true for all levels of the business objects.

See the below sample code of a business object, Employees, encapsulating Orders information from the Orders table.

<GetEmployeesObjectResponse xmlns="...">
 <tuple>
   <old>
     <Employees>
     <EmployeeID>1</EmployeeID>
     <Orders>
  <OrderID>10248</OrderID>
     </Orders>
     <Orders>
  <OrderID>10258</OrderID>
     </Orders>
     </Employees>
   </old>
 </tuple>
</ GetEmployeesObjectResponse>

Here, EmployeeID and OrderID are business elements. The current context of the OrderID is Orders.

Any business element that repeats within the business object or contains elements inside it is considered as current context. The business elements inside this element are referred through the current context.
Instances of data with current contexts:

  • The associated data of a parent data retrieved from a database.
  • Every block of entry with business elements having multiple values retrieved from LDAP.

Current context is retrieved by executing an XPath reference on the business element of a business object that has multiple values.

Current Context States

A state of a business element cannot be independent of and is always dependent on the state of the business object. However, based on the interactions you do for the business elements of the current contexts, its state may differ.

  1. READ: This is the default state after data is retrieved from server. Business object will have a tuple/old representation.
  2. UPDATE: When a business element of a current context is modified, it is considered as an update on the business object. So, business object will have tuple/old and tuple/new tags. The new tag holds the modified current context, while the old contains the original status of the data.
  3. INSERT: An insert in the current context is also considered as an update of the business object.
  4. DELETE: Same as update and insert, a delete is a removal of one or more current contexts inside a business object. So, business object will have an update status.

Non-transactional Data

Current contexts can also be represented inside a non-transactional business object. For non-transactional data, the business object does not have a tuple/old or tuple/new protocol. Consider the following data.
In the following code, Supplies is the current context of the business element SupplyID .

<items>
    <item>
        <itemID>10</itemID>
        <supplies>
            <supplyID>1</supplyID>
        </supplies>
    </item>
</items>

Setting References

Since there can be zero or more current contexts in a business object, the model should not be set on the control associated with a current context. Instead, bind the current context data as follows:

  1. Create a grouping control for setting the model.
  2. Create a table for the current context, and set reference of the current context to the table.

Only the following controls can be used to represent data in a current context:

  • Select control: A Select control can represent the current context elements as multiple values. To enable multiple-values option, check Enumerated in the property sheet of the Select control, and set the Reference property as current context.
  • Table control: Set the Reference property of the Table control as the current context. Set the Reference property for the controls in the Table control as the business elements inside the current context.

Retrieving Current Context

The following are some possibilities to retrieve current context:

HTML Controls

controlID.currentContext

Table rows

rowObject.currentContext

Applies to

HTML Controls

Related reference

Business Object
xforms-change
xforms-onafterchange
xforms-onbeforechange